import 'dart:convert';

import 'package:http/http.dart' as http;
import 'package:robot3/pojo.dart';
import 'Robot.dart'; // For devicePixelRatio



Future<bool> login() async {
  print("login start");
  var url = Uri.https(host, 'robot/login');
  var response = await http.post(url, body: {'sn': Robot.sn});
  var a = ApiResponse<LoginBean>.fromJson(jsonDecode(response.body),
          (data) => LoginBean.fromJson(data)); // 传递一个从 JSON 解析 LoginBean 的方法);

  print(a.data.toString());
  if (a.data?.userId == null) {
    print('请扫码');
    return false;
  }
Robot.userId = a.data!.userId!;
Robot.companyId = a.data!.companyId!;
Robot.accessToken = a.data!.accessToken!;
print("Robot.accessToken:"+Robot.accessToken);
  print("login end");
  return true;
}

const String host = 'applet.xmlights.com';
const  double  ratio= 3.5 ;
